home *** CD-ROM | disk | FTP | other *** search
Text File | 2003-10-20 | 53.9 KB | 2,006 lines |
- function ext_XML_GET_TEXT()
- {
- return this.firstChild.nodeType != 3 ? null : this.firstChild.nodeValue;
- }
- function ext_XML_SET_TEXT(text)
- {
- this.firstChild.nodeValue = text;
- }
- function ActivityInfoItem()
- {
- }
- function ActivityInfo()
- {
- }
- function createIndexList(str, openTag, closeTag)
- {
- var len = str.length;
- var acntr = 0;
- var otag = openTag;
- var ctag = closeTag;
- var abi = [];
- var aei = [];
- while(acntr < len)
- {
- acntr = str.indexOf(otag,acntr);
- if(acntr == -1)
- {
- break;
- }
- abi.push(acntr);
- acntr += otag.length;
- }
- acntr = 0;
- while(acntr < len)
- {
- acntr = str.indexOf(ctag,acntr);
- if(acntr == -1)
- {
- break;
- }
- aei.push(acntr);
- acntr += ctag.length;
- }
- var rf = otag.length + ctag.length;
- var i = 0;
- while(i < abi.length)
- {
- if(i == 0)
- {
- aei[i] -= ctag.length - 1;
- }
- else
- {
- abi[i] -= rf * i;
- aei[i] -= rf * i + otag.length;
- }
- i++;
- }
- return {startIndex:abi,endIndex:aei,length:abi.length};
- }
- function createInstructionField(cnt, name, text)
- {
- text = simpleReplaceBlanks(text,"[:blank:]","[:/blank:]");
- var hasBold = text.indexOf("[:bold:]") != -1;
- if(cnt[name] == null)
- {
- var tmc = cnt.createEmptyMovieClip(name,1667);
- tmc.createTextField("content",1,0,0,0,0);
- }
- else
- {
- var tmc = cnt[name];
- tmc.swapDepths(1667);
- }
- tmc.isRemoveable = true;
- tmc.isRemovable = true;
- var tf = layoutInfo.instTextFormat;
- tmc.content.border = false;
- tmc.content.type = "dynamic";
- if(hasBold)
- {
- tmc.content.text = text.replace("[:bold:]","").replace("[:/bold:]","");
- }
- else
- {
- tmc.content.text = text;
- }
- tmc.content._height = 400;
- tmc.content.wordWrap = true;
- tmc.content.color = layoutInfo.instTextColor;
- tmc.content._width = 300;
- tmc.content.autoSize = true;
- tmc.content.selectable = false;
- tmc.content.setTextFormat(tf);
- tmc.content.embedFonts = true;
- if(hasBold)
- {
- var idxLists = createIndexList(text,"[:bold:]","[:/bold:]");
- var i = 0;
- while(i < idxLists.length)
- {
- tmc.content.setTextFormat(idxLists.startIndex[i],idxLists.endIndex[i],layoutInfo.instTextFormatBold);
- i++;
- }
- }
- return tmc;
- }
- function changeInstructionField(insField, newText)
- {
- createInstructionField(insField._parent,insField._name,newText);
- }
- function toggleLang()
- {
- if(PMSI.instructionLanguage == "Spanish")
- {
- PMSI.instructionLanguage = "English";
- }
- else
- {
- PMSI.instructionLanguage = "Spanish";
- }
- var instText = ai["instructions" + PMSI.instructionLanguage].text;
- if(instText != null)
- {
- var oldInstHeight = this.instructionField._height;
- changeInstructionField(this.instructionField,instText);
- var hdiff = this.instructionField._height - oldInstHeight;
- reposition(hdiff);
- }
- pencilHelper.swapLangs();
- }
- function reposition(hdiff)
- {
- var comp;
- var dupList = {};
- trace("******************************************");
- for(var mcn in this)
- {
- comp = this[mcn];
- if(comp.isMoveable && dupList[comp._name] == null)
- {
- trace("\t" + comp);
- trace("\t\t" + comp.getDepth());
- trace(hdiff);
- comp._y += hdiff;
- dupList[comp._name] = 1;
- }
- }
- trace("******************************************");
- }
- function simpleReplaceBlanks(str, stag, etag)
- {
- var cp = str.indexOf(stag);
- var ei = 0;
- while(cp != -1)
- {
- ei = str.indexOf(etag);
- str = str.substring(0,cp) + "_____" + str.substring(ei + etag.length);
- cp = str.indexOf(stag);
- }
- return str;
- }
- function loadActivity(fname)
- {
- t = getTimer();
- ai.load(fname);
- }
- function setActivityInfo(_ai)
- {
- ai = _ai;
- ai._parent = this;
- render();
- return true;
- }
- function render()
- {
- delete imageArray;
- imageArray = new Array();
- tabOrder = 4000;
- this.hasImages = false;
- if(_parent == null)
- {
- this.lineStyle(1,0,100);
- this.drawRect(0,0,Stage.width,Stage.height);
- }
- clearClip();
- this.attachMovie("pencil","pencil",60001);
- pencil.isRemovable = true;
- pencilSelected = false;
- if(this.needsTip == true)
- {
- this.attachMovie("pencil_tip","pencilHelper",70000);
- pencilHelper.isRemovable = true;
- }
- pencil.isRemovable = true;
- pencil.swapDepths(60001);
- pencilHelper.swapDepths(60000);
- pencil._visible = false;
- resetBubbleTimer();
- tableY = layoutInfo.box.y;
- rightSideBuffer = layoutInfo.rightSideBuffer;
- topBuffer = 0;
- if(master.hasVideoPlayer)
- {
- tableY = layoutInfo.temp4InstY;
- topBuffer = master.videoPlayer._height;
- rightSideBuffer = 250;
- }
- else if(master.hasMediaFrame)
- {
- rightSideBuffer = 250;
- }
- table = new TableClass(this);
- trace(this + ".render: called");
- var title_mc;
- var inst_mc;
- if(ai.titleSpanish)
- {
- title_mc = createTitleField(ai.titleSpanish);
- title_mc.isRemovable = true;
- title_mc._x = layoutInfo.box.x;
- title_mc._y = layoutInfo.box.y + topBuffer;
- tableY = title_mc._y + title_mc._height;
- }
- if(ai.instructionsEnglish == null && ai.instructionsSpanish == null)
- {
- ai.instructionsEnglish = {text:ai.questions.question.questionText.text};
- ai.instructionsSpanish = {text:ai.questions.question.questionTextSpanish.text};
- ai.questions.question.questionText = null;
- ai.questions.question.questionTextSpanish = null;
- }
- if(ai.instructionsEnglish || ai.instructionsSpanish)
- {
- if(ai.instructionsEnglish != null)
- {
- var instText = ai.instructionsEnglish.text;
- }
- else
- {
- var instText = ai.instructionsSpanish.text;
- }
- pinstText = ai["instructions" + PMSI.instructionLanguage].text;
- instText = pinstText != null ? pinstText : instText;
- inst_mc = this.createInstructionField(this,"inst",instText);
- inst_mc.isRemovable = true;
- inst_mc._x = layoutInfo.box.x;
- inst_mc._y = title_mc == null ? tableY : title_mc._y + title_mc._height;
- trace("INST Y: " + inst_mc._y);
- this.instructionField = inst_mc;
- tableY = inst_mc._y + inst_mc._height;
- }
- if(ai.reference != null)
- {
- this._parent.showRefWinButton(layoutInfo.box.x,tableY);
- }
- if(_parent.actNumber_mc._height > inst_mc._height + title_mc._height)
- {
- tableY = _parent.actNumber_mc._y + _parent.actNumber_mc._height + 10;
- }
- else
- {
- tableY += 10;
- }
- var questionY = 0;
- var qlen = ai.questions.question.length;
- var qs = ai.questions.question;
- var ans = ai.wordbank.word;
- var qlen = qs.length;
- container.clampsLeft = new Array(qlen);
- container.clampsRight = new Array(qlen);
- var clwid = layoutInfo.matchingCircleLineThickness;
- var crad = layoutInfo.matchingCircleRadius;
- var cwid = crad + clwid;
- var voff = layoutInfo.matchingCircleVertOffset;
- var dboxw = cwid * 2;
- var i = 0;
- while(i < qlen)
- {
- tr = new TableRow();
- var mc;
- if(ai.questions.question[i].questionText != null)
- {
- this.hasImages = false;
- mc = container.createQuestionField(i,ai.questions.question[i].questionText);
- }
- else
- {
- mc = container.attachMovie("imgPlaceHolder","img" + i,5200 + i);
- mc._visible = false;
- imageArray.push(mc);
- this.hasImages = true;
- imageLoader.addImage({clip:mc.createEmptyMovieClip("img",1),url:"artfiles/" + ai.questions.question[i].artFile});
- }
- mc.isRemovable = true;
- mc.isMoveable = true;
- if(this.hasImages)
- {
- voff = 0;
- }
- cmc = container.createEmptyMovieClip("qcirc" + i,4200 + i);
- cmc.lineStyle(clwid,layoutInfo.matchingCircleColor,100);
- cmc.beginFill(16777215);
- cmc.drawOval(cwid,cwid + voff,crad);
- cmc.voff = voff;
- cmc.endFill();
- cmc.isRemovable = true;
- cmc.isMoveable = true;
- cmc.answerText = ai.questions.question[i].correctAnswer.text;
- clampsLeft[i] = cmc;
- cmc.tabIndex = tabOrder++;
- amc = container.createEmptyMovieClip("acirc" + i,4300 + i);
- amc.lineStyle(clwid,layoutInfo.matchingCircleColor,100);
- amc.beginFill(16777215);
- amc.drawOval(cwid,cwid + voff,crad);
- amc.voff = voff;
- amc.endFill();
- amc.isRemovable = true;
- amc.isMoveable = true;
- amc.answerText = ans[i].text;
- clampsRight[i] = amc;
- amc.tabIndex = tabOrder++;
- var rst = createAnswerField(i,1,ans[i]);
- rst.isRemovable = true;
- rst.isMoveable = true;
- var spacer = createAnswerSpacer(id);
- spacer.isRemovable = true;
- spacer.isMoveable = true;
- feedbackCheck = this.attachMovie("check","correctcheck_" + i,4400 + i);
- feedbackCheck.isRemovable = true;
- feedbackCheck.isMoveable = true;
- amc.feedbackCheck = feedbackCheck;
- cmc.feedbackCheck = feedbackCheck;
- tc0 = new TableCell(feedbackCheck);
- tc0.setVAlign("center");
- tc1 = new TableCell(mc);
- tc2 = new TableCell(cmc);
- tc2.setHAlign("center");
- if(this.hasImages)
- {
- tc2.setVAlign("center");
- }
- tc3 = new TableCell(spacer);
- tc4 = new TableCell(amc);
- tc4.setHAlign("center");
- if(this.hasImages)
- {
- tc4.setVAlign("center");
- }
- tc5 = new TableCell(rst);
- if(this.hasImages)
- {
- tc5.setVAlign("center");
- }
- tr.addCell(tc0);
- tr.addCell(tc1);
- tr.addCell(tc2);
- tr.addCell(tc3);
- tr.addCell(tc4);
- tr.addCell(tc5);
- table.addRow(tr);
- i++;
- }
- if(this.hasImages == null || this.hasImages == false)
- {
- table.setBorder(0);
- leftAdjust = 0;
- table.setPosition({x:layoutInfo.box.x + leftAdjust,y:tableY + 4});
- table.setCellSpacing(6);
- table.init();
- trace("TABLE WIDTH: " + (layoutInfo.MAX_WIDTH - rightSideBuffer));
- trace("TABLE Y: " + tableY);
- var twid = layoutInfo.MAX_WIDTH - rightSideBuffer - 10;
- table.setWidth(layoutInfo.MAX_WIDTH - rightSideBuffer - 20);
- }
- clamps = clampsLeft.concat(clampsRight);
- var i = 0;
- while(i < clampsLeft.length)
- {
- clampsLeft[i].leftClamp = true;
- clampsLeft[i].onPress = startLine;
- clampsLeft[i].onRelease = stopLine;
- clampsLeft[i].onReleaseOutside = clampReleaseOutside;
- clampsLeft[i].useHandCursor = false;
- clampsLeft[i].onRollOver = clampRollOver;
- clampsLeft[i].onRollOut = clampRollOut;
- i++;
- }
- var i = 0;
- while(i < clampsRight.length)
- {
- clampsRight[i].rightClamp = true;
- clampsRight[i].onPress = startLine;
- clampsRight[i].onRelease = stopLine;
- clampsRight[i].onReleaseOutside = clampReleaseOutside;
- clampsRight[i].useHandCursor = false;
- clampsRight[i].onRollOver = clampRollOver;
- clampsRight[i].onRollOut = clampRollOut;
- i++;
- }
- trace("SETTING PENCIL HELPER: x: " + clampsRight);
- pencilHelper._x = clamps[0]._x + clamps[0]._width;
- pencilHelper._y = clamps[0]._y + clamps[0]._height / 2;
- pencilHelper.isMoveable = true;
- if(this.hasImages)
- {
- for(var mcn in this)
- {
- if(this[mcn].isRemovable)
- {
- this[mcn]._visible = false;
- }
- }
- imageLoader.start();
- }
- }
- function clampReleaseOutside()
- {
- stopLine(this);
- pencil._visible = false;
- Mouse.show();
- }
- function clampRollOver()
- {
- pencil._visible = true;
- pencilSelected = true;
- pencil._x = _root._xmouse;
- pencil._y = _root._ymouse;
- pencilHolder.onRelease = pencilHolderRelease;
- Mouse.hide();
- pencil.onMouseMove = pencilOnMouseMove;
- }
- function clampRollOut()
- {
- pencilSelected = true;
- pencil._visible = false;
- delete pencilHolder.onRelease;
- Mouse.show();
- }
- function pencilOnMouseMove()
- {
- this._x = _root._xmouse;
- this._y = _root._ymouse;
- updateAfterEvent();
- }
- function startLine()
- {
- if(pencilSelected)
- {
- this.line.clear();
- this.line.removeMovieClip();
- delete this.line;
- this.targetline.clear();
- this.targetline = null;
- if(this.line == null)
- {
- container.drawLines_mcs.level = container.drawLines_mcs.level + 1;
- this.line = container.createEmptyMovieClip("__drawline__" + container.drawLines_mcs.level,container.drawLines_mcs.level);
- container.drawLines_mcs[this] = this.line;
- this.line.createTextField("no",0,0,30,30);
- this.line.no.text = container.drawLines_mcs.level;
- this.line.isRemovable = true;
- this.line.isMoveable = true;
- }
- container._currentClamp = this;
- this._orgX = _root._xmouse;
- this._orgY = _root._ymouse;
- this.onMouseMove = container.drawLine;
- }
- }
- function drawLine()
- {
- var lx = _root._xmouse;
- var ly = _root._ymouse;
- var ox = this._orgX;
- var oy = this._orgY;
- if(container._snapLines && !container._snapAfter)
- {
- var targ = container.checkForHit(this);
- if(targ)
- {
- var tpt = targ.getCenterPoint();
- targ.localToGlobal(tpt);
- lx = tpt.x;
- ly = tpt.y + this.voff;
- }
- var mpt = this.getCenterPoint();
- this.localToGlobal(mpt);
- ox = mpt.x;
- oy = mpt.y + this.voff;
- }
- this.line.clear();
- this.line.lineStyle(3,lineColor,lineAlpha);
- this.line.moveTo(ox,oy);
- this.line.lineTo(lx,ly);
- updateAfterEvent();
- }
- function stopLine(targetClip)
- {
- var thisTarg = targetClip != null ? targetClip : this;
- var targ = container.checkForHit(thisTarg);
- if(container._snapAfter)
- {
- thisTarg.line.clear();
- thisTarg.line.lineStyle(3,lineColor,70);
- thisTarg.line.moveTo(thisTarg._x,thisTarg._y);
- thisTarg.line.lineTo(targ._x,targ._y);
- }
- if(targ.line != targ.targetline)
- {
- targ.line.clear();
- }
- targ.targetline.clear();
- targ.targetline = thisTarg.line;
- if(targ == null)
- {
- thisTarg.line.clear();
- delete targ._matchTo;
- delete thisTarg._matchTo;
- }
- else
- {
- pencilHelper.gotoAndStop(1);
- pencilHelper.unloadMovie();
- pencilHelper.neverRunAgain = true;
- needsTip = false;
- neverRunPencilTipAgain = true;
- targ._matchTo = thisTarg;
- thisTarg._matchTo = targ;
- }
- delete thisTarg.onMouseMove;
- }
- function checkForHit(oClamp)
- {
- var clamp = null;
- var i = 0;
- while(i < clamps.length)
- {
- clamp = clamps[i];
- if(clamp.hitTest(_root._xmouse,_root._ymouse) && !(clamp.rightClamp && oClamp.rightClamp) && !(clamp.leftClamp && oClamp.leftClamp))
- {
- return clamp;
- }
- i++;
- }
- return null;
- }
- function pencilHolderRelease()
- {
- pencilSelected = false;
- delete pencil.onMouseMove;
- Mouse.show();
- checkAnswers();
- delete pencilHolder.onRelease;
- }
- function changeSnap()
- {
- container._snapAfter = snapAfterRB.getState();
- container._snapLines = snapDuringRB.getState();
- }
- function checkAnswers()
- {
- var correct = 0;
- var cml;
- var cmlm;
- var i = 0;
- while(i < clampsLeft.length)
- {
- cml = clampsLeft[i].answerText;
- cmlm = clampsLeft[i]._matchTo.answerText;
- if(cml == cmlm)
- {
- correct++;
- clampsLeft[i].feedbackCheck.gotoAndStop("correct");
- }
- else
- {
- clampsLeft[i].feedbackCheck.gotoAndStop("incorrect");
- }
- i++;
- }
- master.setFeedback(correct,clampsLeft.length);
- }
- function createQuestionField(id, text)
- {
- var mc = this.createEmptyMovieClip("question" + id,4500 + id);
- mc.createTextField("content",1,0,0,0,0);
- var tf = layoutInfo.qTextFormatMATCH;
- mc.content.embedFonts = true;
- mc.content.border = false;
- mc.content.type = "dynamic";
- mc.content.text = text;
- mc.content.autoSize = true;
- mc.content.setTextFormat(tf);
- mc.content.selectable = false;
- return mc;
- }
- function createAnswerField(id, subid, text)
- {
- var amc1 = this.createEmptyMovieClip("answer" + subid + "_" + id,4600 + id);
- amc1.createTextField("content",1,0,0,0,0);
- var tf2 = layoutInfo.answerTextFormat1;
- amc1.content.embedFonts = true;
- amc1.content.border = false;
- amc1.content.type = "dynamic";
- amc1.content.text = text;
- amc1.content.autoSize = true;
- amc1.content.selectable = false;
- amc1.content.setTextFormat(tf2);
- return amc1;
- }
- function createAnswerFieldStatic(id, subid, text)
- {
- var amc1 = this.createEmptyMovieClip("answer" + subid + "_" + id,4700 + id);
- amc1.createTextField("content",1,0,0,0,0);
- var tf2 = layoutInfo.answerTextFormat1;
- amc1.content.embedFonts = true;
- amc1.content.border = false;
- amc1.content.type = "dynamic";
- amc1.content.text = text;
- amc1.content.autoSize = true;
- amc1.content.selectable = false;
- amc1.content.setTextFormat(tf2);
- return amc1;
- }
- function createAnswerSpacer(id)
- {
- var amcSpacer = this.createEmptyMovieClip("answerSpacer_" + id,4800 + id);
- amcSpacer.createTextField("content",1,0,0,0,0);
- var tf2 = layoutInfo.answerTextFormat1;
- amcSpacer.content.embedFonts = true;
- amcSpacer.content.border = false;
- amcSpacer.content.type = "dynamic";
- amcSpacer.content.text = " ";
- amcSpacer.content.autoSize = true;
- amcSpacer.content.setTextFormat(tf2);
- amcSpacer.content.selectable = false;
- return amcSpacer;
- }
- function createTitleField(txt)
- {
- var mc = this.createEmptyMovieClip("title",4900);
- mc.createTextField("content",1,0,0,0,0);
- var tf = layoutInfo.titleTextFormat;
- mc.content.embedFonts = true;
- mc.content.border = false;
- mc.content.type = "dynamic";
- mc.content.text = txt;
- mc.content.setTextFormat(tf);
- mc.content.wordWrap = true;
- mc.content.color = layoutInfo.instTextColor;
- mc.content._width = 300;
- mc.content.autoSize = true;
- mc.content.selectable = false;
- return mc;
- }
- function clearClip()
- {
- delete clampsLeft;
- delete clampsRight;
- delete clamps;
- delete table;
- pencilHelper.gotoAndStop(1);
- layoutInfo.qMaxWidthPos = 0;
- layoutInfo.qMaxWidth = 0;
- layoutInfo.a1MaxWidth = 0;
- layoutInfo.a2MaxWidth = 0;
- for(var mcn in this)
- {
- if(this[mcn].isRemovable)
- {
- trace("Deleting: " + mcn);
- this[mcn].clear();
- this[mcn].removeMovieClip();
- }
- }
- }
- function bubbleHelpInterval()
- {
- pencilHelper.gotoAndStop(1);
- if(!PMSI.isVideoPlaying && bubblePlayCounter <= bubblePlayMax)
- {
- bubblePlayCounter++;
- pencilHelper.play();
- clearInterval(bubbleHelpIntId);
- }
- }
- function resetBubbleTimer()
- {
- pencilHelper.gotoAndStop(1);
- if(pencilHelper != undefined)
- {
- clearInterval(bubbleHelpIntId);
- bubbleHelpIntId = setInterval(this,"bubbleHelpInterval",bubbleHelpSleepTime * 1000);
- }
- }
- if(_global.PMSI == null)
- {
- _global.PMSI = {};
- PMSI.VENDOR_NAME = "Purple Monkey Studios, Inc.";
- PMSI.DefList = {};
- }
- String.prototype.trim = function()
- {
- return this.rtrim().ltrim();
- };
- String.prototype.rtrim = function()
- {
- var i = this.length - 1;
- while(i >= 0 && this.charCodeAt(i) <= 32)
- {
- i--;
- }
- return this.substring(0,i + 1);
- };
- String.prototype.ltrim = function()
- {
- var i = 0;
- while(i < this.length && this.charCodeAt(i) <= 32)
- {
- i++;
- }
- return this.substring(i);
- };
- String.prototype.isWhiteSpace = function()
- {
- var i = 0;
- while(i < this.length)
- {
- if(this.charCodeAt(i) > 32)
- {
- return false;
- }
- i++;
- }
- return true;
- };
- String.prototype.toCharArray = function()
- {
- return this.split("");
- };
- Array.prototype.charArrayToString = function()
- {
- return this.join("");
- };
- String.prototype.reverse = function()
- {
- return this.split("").reverse().join("");
- };
- String.prototype.multiSplit = function()
- {
- var master;
- var dummy;
- var args;
- master = this.split(arguments[0]);
- var i = 1;
- while(i < arguments.length)
- {
- var j = 0;
- while(j < master.length)
- {
- dummy = master[j].split(arguments[i]);
- if(dummy.length > 1)
- {
- args = [j,1];
- args = args.concat(dummy);
- master.splice.apply(master,args);
- }
- j++;
- }
- i++;
- }
- return master;
- };
- String.prototype.replace = function(srch, repl)
- {
- return this.split(srch).join(repl);
- };
- XML.prototype.ELEMENT_NODE = 1;
- XML.prototype.TEXT_NODE = 3;
- XML.prototype._inorderItr = function(node, fnPtr)
- {
- var stack = new Array();
- var node = node;
- while(true)
- {
- if(node)
- {
- stack.push(node);
- node = node.firstChild;
- }
- else
- {
- node = stack.pop();
- if(!node)
- {
- break;
- }
- fnPtr(node);
- node = node.nextSibling;
- }
- }
- delete stack;
- };
- XMLNode.prototype._inorderItr = XML.prototype._inorderItr;
- XML.prototype._inorderRec = function(node, fnPtr)
- {
- function helperR(node_xml)
- {
- if(node_xml == null)
- {
- return undefined;
- }
- this.fnPtr(node_xml);
- helperR(node_xml.firstChild);
- helperR(node_xml.nextSibling);
- }
- var outer = this;
- helperR(node);
- };
- XMLNode.prototype._inorderRec = XML.prototype._inorderRec;
- XMLNode.prototype.addProperty("text",this.ext_XML_GET_TEXT,this.ext_XML_SET_TEXT);
- XML.prototype.addProperty("text",this.ext_XML_GET_TEXT,this.ext_XML_SET_TEXT);
- XML.prototype.getElementsByTagName = function(tagName)
- {
- function processNode(node)
- {
- if(node.nodeName != null && node.nodeName == tagName)
- {
- nodelist.push(node);
- }
- }
- var nodelist = new Array();
- this._inorderItr(this,processNode);
- return nodelist;
- };
- XMLNode.prototype.getElementsByTagName = XML.prototype.getElementsByTagName;
- XML.prototype.getElementsByTagNames = function()
- {
- function processNode(node)
- {
- var i = 0;
- while(i < args.length)
- {
- if(node.nodeName != null && node.nodeName == args[i])
- {
- trace("Found: " + args[i]);
- if(nodelists[i] == undefined)
- {
- nodelists[i] = new Array();
- }
- nodelists[i].push(node);
- break;
- }
- i++;
- }
- }
- var args = arguments;
- var nodelists = new Array(arguments.length);
- this._inorderItr(this,processNode);
- return nodelists;
- };
- XMLNode.prototype.getElementsByTagNames = XML.prototype.getElementsByTagNames;
- XML.prototype.getValueAtTagName = function(tagName)
- {
- function processNode(node)
- {
- if(node.nodeName != null && node.nodeName == tagName)
- {
- nodelist.push(node);
- }
- }
- var nodelist = new Array();
- var textValue = null;
- this._inorderItr(this,processNode);
- if(nodeList.length >= 1)
- {
- textValue = nodeList[0].text;
- }
- return textValue;
- };
- XMLNode.prototype.getValueAtTagName = XML.prototype.getValueAtTagName;
- XML.prototype.getAttribute = function(name)
- {
- return this.attributes[name];
- };
- XMLNode.prototype.getAttribute = XML.prototype.getAttribute;
- XML.prototype.setAttribute = function(name, value)
- {
- this.attributes[name] = value;
- };
- XMLNode.prototype.setAttribute = XML.prototype.setAttribute;
- XML.prototype.hasAttribute = function(name)
- {
- var attrs = this.attributes;
- for(var mc in attrs)
- {
- if(name == mc)
- {
- return true;
- }
- }
- return false;
- };
- XMLNode.prototype.hasAttribute = XML.prototype.hasAttribute;
- XML.prototype.removeAttribute = function(name)
- {
- var attr = this.attributes[name];
- delete this.attributes[name];
- return attr;
- };
- XMLNode.prototype.setAttribute = XML.prototype.setAttribute;
- XMLNode.prototype.getOwnerDocument = function()
- {
- var odc = this;
- var lastNode = this;
- while(odc)
- {
- lastNode = odc;
- odc = odc.parentNode;
- }
- return !(lastNode instanceof XML) ? null : lastNode;
- };
- XML.prototype.normalize = function()
- {
- function process(node)
- {
- nodeList.push(node);
- }
- var outer = this;
- var nodeList = new Array();
- this._inorderItr(this,process);
- var i = 0;
- while(i < nodeList.length)
- {
- var node = nodeList[i];
- if(node.nodeType == XML.prototype.TEXT_NODE && node.nodeValue.isWhiteSpace())
- {
- trace("removing node");
- node.removeNode();
- }
- else if(node.nodeType == XML.prototype.TEXT_NODE)
- {
- node.nodeValue = node.nodeValue.trim();
- }
- i++;
- }
- delete nodeList;
- };
- XMLNode.prototype.normalize = XML.prototype.normalize;
- XMLNode.prototype.getDepth = function()
- {
- var i = 0;
- var node = this;
- while(node)
- {
- node = node.parentNode;
- i++;
- }
- return i;
- };
- XML.prototype.getElementsWithAttribute = function(name, value)
- {
- function processNode(node)
- {
- if(value == null)
- {
- for(var mcz in node.attributes)
- {
- if(mcz == name)
- {
- nodeList.push(node);
- break;
- }
- }
- }
- else if(node.attributes[name] == value)
- {
- nodeList.push(node);
- }
- }
- if(name == null)
- {
- return undefined;
- }
- var nodeList = new Array();
- this._inorderItr(this,processNode);
- return nodeList;
- };
- XMLNode.prototype.getElementsWithAttribute = XML.prototype.getElementsWithAttribute;
- XMLNode.prototype.getPath = function(path)
- {
- function process(node)
- {
- trace(node.nodeName);
- if(node.nodeName != null && node.nodeName == currentPart && i < pathParts.length)
- {
- trace("Found: " + currentPart);
- partTable[i] = node.parentNode.getElementsByTagName(currentPart);
- currentPart = pathParts[++i];
- }
- }
- var i = 0;
- var pathParts = path.split("/");
- var currentPart = pathParts[i];
- var partTable = new Array();
- this._inorderItr(this,process);
- return partTable[partTable.length - 1];
- };
- XML.prototype.getPath = XMLNode.prototype.getPath;
- MovieClip.prototype.isLoading = function()
- {
- return this.getBytesLoaded() > 4 && this.getBytesTotal() > this.getBytesLoaded();
- };
- MovieClip.prototype.getPercentLoaded = function()
- {
- return Math.round(this.getBytesLoaded() / this.getBytesTotal() * 100);
- };
- MovieClip.prototype.isLoaded = function()
- {
- return !this.isLoading();
- };
- MovieClip.prototype._sol = function(f)
- {
- if(MovieClip.prototype.__onLoadHandler__ == undefined)
- {
- MovieClip.prototype.__onLoadHandler__ = {};
- }
- MovieClip.prototype.__onLoadHandler__[this] = f;
- };
- MovieClip.prototype._gol = function()
- {
- return MovieClip.prototype.__onLoadHandler__[this];
- };
- MovieClip.prototype.addProperty("onLoad",MovieClip.prototype._gol,MovieClip.prototype._sol);
- MovieClip.prototype._sod = function(f)
- {
- if(MovieClip.prototype.__onDataHandler__ == undefined)
- {
- MovieClip.prototype.__onDataHandler__ = {};
- }
- MovieClip.prototype.__onDataHandler__[this] = f;
- };
- MovieClip.prototype._god = function()
- {
- return MovieClip.prototype.__onDataHandler__[this];
- };
- MovieClip.prototype.addProperty("onData",MovieClip.prototype._god,MovieClip.prototype._sod);
- MovieClip.prototype.load = MovieClip.prototype.loadMovie;
- MovieClip.prototype.drawOval = function(x, y, radius, yRadius)
- {
- if(arguments.length < 3)
- {
- return undefined;
- }
- var theta;
- var xrCtrl;
- var yrCtrl;
- var angle;
- var angleMid;
- var px;
- var py;
- var cx;
- var cy;
- if(yRadius == undefined)
- {
- yRadius = radius;
- }
- theta = 0.7853981633974483;
- xrCtrl = radius / Math.cos(theta / 2);
- yrCtrl = yRadius / Math.cos(theta / 2);
- angle = 0;
- this.moveTo(x + radius,y);
- var i = 0;
- while(i < 8)
- {
- angle += theta;
- angleMid = angle - theta / 2;
- cx = x + Math.cos(angleMid) * xrCtrl;
- cy = y + Math.sin(angleMid) * yrCtrl;
- px = x + Math.cos(angle) * radius;
- py = y + Math.sin(angle) * yRadius;
- this.curveTo(cx,cy,px,py);
- i++;
- }
- };
- MovieClip.prototype.drawCircle = function(x, y, r)
- {
- this.drawOval(x,y,r);
- };
- MovieClip.prototype.drawSquare = function(x, y, w)
- {
- this.drawRect(x,y,w,w);
- };
- MovieClip.prototype.drawEgg = function(x, y, r)
- {
- var rx = r / 1.618;
- var ry = r;
- var ry1 = 2 * ry * 0.618;
- var ry2 = 2 * ry * 0.382;
- this.moveTo(x + rx,y);
- this.curveTo(rx + x,-0.4142 * ry1 + y,0.7071 * rx + x,-0.7071 * ry1 + y);
- this.curveTo(0.4142 * rx + x,- ry1 + y,x,- ry1 + y);
- this.curveTo(-0.4142 * rx + x,- ry1 + y,-0.7071 * rx + x,-0.7071 * ry1 + y);
- this.curveTo(- rx + x,-0.4142 * ry1 + y,- rx + x,y);
- this.curveTo(- rx + x,0.4142 * ry2 + y,-0.7071 * rx + x,0.7071 * ry2 + y);
- this.curveTo(-0.4142 * rx + x,ry2 + y,x,ry2 + y);
- this.curveTo(0.4142 * rx + x,ry2 + y,0.7071 * rx + x,0.7071 * ry2 + y);
- this.curveTo(rx + x,0.4142 * ry2 + y,rx + x,y);
- };
- MovieClip.prototype.drawRect = function(x, y, w, h, cornerRadius)
- {
- if(arguments.length < 4)
- {
- return undefined;
- }
- if(cornerRadius > 0)
- {
- var theta;
- var angle;
- var cx;
- var cy;
- var px;
- var py;
- if(cornerRadius > Math.min(w,h) / 2)
- {
- cornerRadius = Math.min(w,h) / 2;
- }
- theta = 0.7853981633974483;
- this.moveTo(x + cornerRadius,y);
- this.lineTo(x + w - cornerRadius,y);
- angle = -1.5707963267948966;
- cx = x + w - cornerRadius + Math.cos(angle + theta / 2) * cornerRadius / Math.cos(theta / 2);
- cy = y + cornerRadius + Math.sin(angle + theta / 2) * cornerRadius / Math.cos(theta / 2);
- px = x + w - cornerRadius + Math.cos(angle + theta) * cornerRadius;
- py = y + cornerRadius + Math.sin(angle + theta) * cornerRadius;
- this.curveTo(cx,cy,px,py);
- angle += theta;
- cx = x + w - cornerRadius + Math.cos(angle + theta / 2) * cornerRadius / Math.cos(theta / 2);
- cy = y + cornerRadius + Math.sin(angle + theta / 2) * cornerRadius / Math.cos(theta / 2);
- px = x + w - cornerRadius + Math.cos(angle + theta) * cornerRadius;
- py = y + cornerRadius + Math.sin(angle + theta) * cornerRadius;
- this.curveTo(cx,cy,px,py);
- this.lineTo(x + w,y + h - cornerRadius);
- angle += theta;
- cx = x + w - cornerRadius + Math.cos(angle + theta / 2) * cornerRadius / Math.cos(theta / 2);
- cy = y + h - cornerRadius + Math.sin(angle + theta / 2) * cornerRadius / Math.cos(theta / 2);
- px = x + w - cornerRadius + Math.cos(angle + theta) * cornerRadius;
- py = y + h - cornerRadius + Math.sin(angle + theta) * cornerRadius;
- this.curveTo(cx,cy,px,py);
- angle += theta;
- cx = x + w - cornerRadius + Math.cos(angle + theta / 2) * cornerRadius / Math.cos(theta / 2);
- cy = y + h - cornerRadius + Math.sin(angle + theta / 2) * cornerRadius / Math.cos(theta / 2);
- px = x + w - cornerRadius + Math.cos(angle + theta) * cornerRadius;
- py = y + h - cornerRadius + Math.sin(angle + theta) * cornerRadius;
- this.curveTo(cx,cy,px,py);
- this.lineTo(x + cornerRadius,y + h);
- angle += theta;
- cx = x + cornerRadius + Math.cos(angle + theta / 2) * cornerRadius / Math.cos(theta / 2);
- cy = y + h - cornerRadius + Math.sin(angle + theta / 2) * cornerRadius / Math.cos(theta / 2);
- px = x + cornerRadius + Math.cos(angle + theta) * cornerRadius;
- py = y + h - cornerRadius + Math.sin(angle + theta) * cornerRadius;
- this.curveTo(cx,cy,px,py);
- angle += theta;
- cx = x + cornerRadius + Math.cos(angle + theta / 2) * cornerRadius / Math.cos(theta / 2);
- cy = y + h - cornerRadius + Math.sin(angle + theta / 2) * cornerRadius / Math.cos(theta / 2);
- px = x + cornerRadius + Math.cos(angle + theta) * cornerRadius;
- py = y + h - cornerRadius + Math.sin(angle + theta) * cornerRadius;
- this.curveTo(cx,cy,px,py);
- this.lineTo(x,y + cornerRadius);
- angle += theta;
- cx = x + cornerRadius + Math.cos(angle + theta / 2) * cornerRadius / Math.cos(theta / 2);
- cy = y + cornerRadius + Math.sin(angle + theta / 2) * cornerRadius / Math.cos(theta / 2);
- px = x + cornerRadius + Math.cos(angle + theta) * cornerRadius;
- py = y + cornerRadius + Math.sin(angle + theta) * cornerRadius;
- this.curveTo(cx,cy,px,py);
- angle += theta;
- cx = x + cornerRadius + Math.cos(angle + theta / 2) * cornerRadius / Math.cos(theta / 2);
- cy = y + cornerRadius + Math.sin(angle + theta / 2) * cornerRadius / Math.cos(theta / 2);
- px = x + cornerRadius + Math.cos(angle + theta) * cornerRadius;
- py = y + cornerRadius + Math.sin(angle + theta) * cornerRadius;
- this.curveTo(cx,cy,px,py);
- }
- else
- {
- this.moveTo(x,y);
- this.lineTo(x + w,y);
- this.lineTo(x + w,y + h);
- this.lineTo(x,y + h);
- this.lineTo(x,y);
- }
- };
- MovieClip.prototype.getCenterPoint = function()
- {
- return {x:this._width / 2,y:this._height / 2};
- };
- MovieClip.prototype.drawDebugBorderD = function()
- {
- this.lineStyle(1,0,25);
- var x;
- var y = 0;
- var w = this._width;
- var h = this._height;
- this.moveTo(x,y);
- this.lineTo(x + w,y);
- this.lineTo(x + w,y + h);
- this.lineTo(x,y + h);
- this.lineTo(x,y);
- };
- MovieClip.prototype.drawUnderline = function(len)
- {
- len = len != null ? len : this._width;
- this.moveTo(0,this._height);
- this.lineTo(len,this._height);
- };
- if(PMSI.DepthManager == undefined)
- {
- PMSI.DepthManager = {};
- PMSI.DepthManager._$depth = 0;
- PMSI.DepthManager.getNextDepth = function()
- {
- var next_depth = ++this._$depth;
- while(this._$depthsClaimed["dc" + next_depth])
- {
- next_depth = ++this._$depth;
- }
- return next_depth;
- };
- PMSI.DepthManager.reserveDepth = function(d)
- {
- if(this._$depthsClaimed == null)
- {
- this._$depthsClaimed = {};
- }
- if(d == null)
- {
- var d = ++this._$depth;
- }
- while(this._$depthsClaimed["dc" + d])
- {
- d++;
- }
- this._$depthsClaimed["dc" + d] = d;
- return d;
- };
- }
- ActivityInfoItem.prototype.toString = function()
- {
- return this.text;
- };
- ActivityInfo.prototype.getIdString = function(separator)
- {
- var sep = separator != null ? separator : ".";
- var idStr = "C" + this.activity.course + sep;
- idStr += "U" + this.activity.unit + sep;
- idStr += "S" + this.activity.section + sep;
- idStr += this.activity.topic + sep;
- if(this.activity.topicSet)
- {
- idStr += this.activity.topicSet + sep;
- }
- idStr += this.activity.difficultyLevel + this.activity.number.text;
- return idStr;
- };
- ActivityInfo.prototype.getId = ActivityInfo.prototype.getIdString;
- ActivityInfo.prototype.getType = function()
- {
- return this.activity.type;
- };
- ActivityInfo.prototype.hasAudio = function()
- {
- return this.activity.audioFile == null ? false : true;
- };
- ActivityInfo.prototype.hasVideo = function()
- {
- return this.activity.videoFile == null ? false : true;
- };
- ActivityInfo.prototype.hasPicture = function()
- {
- return this.activity.artFile == null ? false : true;
- };
- ActivityInfo.prototype.setResolve = function()
- {
- this.__resolve = ActivityInfo.prototype._myResolve;
- };
- ActivityInfo.prototype._myResolve = function(name)
- {
- return this.activity[name];
- };
- ActivityInfo.prototype.getBytesLoaded = function()
- {
- return this.xmlSource.getBytesLoaded();
- };
- ActivityInfo.prototype.getBytesTotal = function()
- {
- return this.xmlSource.getBytesTotal();
- };
- ActivityInfo.prototype.load = function(url)
- {
- this._reset();
- this.xmlSource = new XML();
- var x = this.xmlSource;
- x.parent = this;
- x.ignoreWhite = true;
- x.createAttributeArray = function(attrs)
- {
- };
- x.onLoad = function(success)
- {
- function helperR(node_xml, obj)
- {
- if(node_xml == null)
- {
- return undefined;
- }
- var nName = node_xml.nodeName;
- if(nName == "number")
- {
- nName = "activityNumber";
- }
- if(nName != null && obj[nName] == null)
- {
- var newObj = new ActivityInfoItem();
- newObj.text = node_xml.text.trim();
- if(node_xml.attributes)
- {
- trace("creating new attributes array");
- newObj.attributes = {};
- for(var oname in node_xml.attributes)
- {
- newObj.attributes[oname] = node_xml.attributes[oname];
- }
- }
- obj[nName] = newObj;
- }
- else if(!(obj[nName] instanceof Array) && obj[nName] != null)
- {
- var temp = obj[nName];
- obj[nName] = [];
- obj[nName].push(temp);
- }
- var childObject = obj[nName];
- if(childObject instanceof Array)
- {
- var newObj = new ActivityInfoItem();
- newObj.text = node_xml.text.trim();
- if(node_xml.attributes)
- {
- trace("creating new attributes array");
- newObj.attributes = {};
- for(var oname in node_xml.attributes)
- {
- newObj.attributes[oname] = node_xml.attributes[oname];
- }
- }
- childObject = newObj;
- obj[nName].push(childObject);
- }
- helperR(node_xml.firstChild,childObject);
- helperR(node_xml.nextSibling,obj);
- }
- if(success)
- {
- helperR(this.firstChild,this.parent);
- this.parent.setResolve();
- }
- this.parent.onLoad(success);
- };
- x.load(url);
- };
- ActivityInfo.prototype._reset = function()
- {
- delete this.xmlSource;
- delete this.__resolve;
- delete this.activity;
- };
- TableClass = function(parent)
- {
- this.parent = parent;
- this.reduceTextFields = true;
- this.rows = [];
- this.maxCellDims = {width:0,height:0};
- this.cellPadding = 4;
- this.cellSpacing = 4;
- this.colWidthMaxs = [];
- this.colPercentTable = [];
- this.borderSize = 1;
- this.width = 0;
- this.height = 0;
- this.oldWidth = this.width;
- this.oldHeight = this.oldHeight;
- this.originalWidth = 0;
- this.x = 0;
- this.y = 0;
- this.alteredColumns = {};
- var dep = PMSI.DepthManager.getNextDepth();
- this.borderClip = parent.createEmptyMovieClip("TableClassBorder" + dep,dep);
- };
- TableClass.prototype.setPosition = function(position)
- {
- this.x = position.x;
- this.y = position.y;
- };
- TableClass.prototype.getPosition = function()
- {
- return {x:this.x,y:this.y};
- };
- TableClass.prototype.setBorder = function(bsize)
- {
- this.borderSize = bsize;
- };
- TableClass.prototype.addRow = function(newRow)
- {
- this.rows.push(newRow);
- var cells = newRow.cells;
- var cellCount = cells.length;
- var cwms = this.colWidthMaxs;
- var cw = null;
- var newWidth = 0;
- var con = null;
- var c = 0;
- while(c < cellCount)
- {
- con = cells[c].getContent();
- cw = con == null ? cells[c].width : con._width;
- if(cwms[c] == null)
- {
- cwms[c] = cw;
- }
- else
- {
- cwms[c] = cw <= cwms[c] ? cwms[c] : cw;
- }
- newWidth += cwms[c];
- c++;
- }
- this.originalWidth = newWidth;
- this.width = newWidth;
- trace("NEW WIDTH: " + this.width);
- };
- TableClass.prototype.addRowSpacer = function(height, width, numCols)
- {
- if(numCols == null && this.rows.length == 0)
- {
- return undefined;
- }
- numCols = this.rows[0].cells.length;
- var spacerRow = new TableRow();
- var spacerCell = null;
- var i = 0;
- while(i < numCols)
- {
- spacerCell = new TableCell();
- spacerCell.height = height;
- spacerCell.width = width;
- spacerRow.addCell(spacerCell);
- i++;
- }
- this.addRow(spacerRow);
- };
- TableClass.prototype.setCellPadding = function(cellPadding)
- {
- this.cellPadding = cellPadding;
- this.redraw();
- };
- TableClass.prototype.setCellSpacing = function(cellSpacing)
- {
- this.cellSpacing = cellSpacing;
- this.redraw();
- };
- TableClass.prototype.setWidth = function(width)
- {
- this.oldWidth = this.width;
- this.width = width;
- this._recalcDimensions(width);
- this.redraw();
- this.redraw();
- };
- TableClass.prototype.setHeight = function(height)
- {
- this.oldHeight = this.height;
- this.height = height;
- this.redraw();
- };
- TableClass.prototype.redraw = function()
- {
- this.borderClip.clear();
- var rows = this.rows;
- var rc = rows.length;
- var tmdims = this.maxCellDims;
- var x;
- var y;
- var r;
- var cc;
- var con;
- var cols;
- var rmdims;
- var cell;
- var cmax;
- var offset;
- var voffset;
- var cwid;
- var wprec;
- var newwid;
- var lastColMax = null;
- var cpad = this.cellPadding;
- var cspace = this.cellSpacing;
- var r = 0;
- while(r < rc)
- {
- cols = rows[r].cells;
- cc = cols.length;
- rmdims = rows[r - 1].maxCellDims;
- if(r == 0)
- {
- y = this.y;
- }
- else
- {
- y += rmdims.height + this.cellSpacing;
- }
- var c = 0;
- while(c < cc)
- {
- cell = cols[c];
- con = cell.getContent();
- cwid = this.colWidthMaxs[c];
- this._resizeTextfield(con,cwid);
- if(cell.halign == "right")
- {
- offset = cwid - con._width;
- }
- else if(cell.halign == "center")
- {
- offset = (cwid - con._width) / 2;
- }
- else
- {
- offset = 0;
- }
- if(cell.valign == "bottom")
- {
- voffset = rows[r].maxCellDims.height - con._height;
- }
- else if(cell.valign == "center")
- {
- voffset = (rows[r].maxCellDims.height - con._height) / 2;
- }
- else
- {
- voffset = 0;
- }
- if(c == 0)
- {
- x = this.x;
- lastColMax = cwid;
- }
- else
- {
- cmax = lastColMax;
- x += cmax + this.cellSpacing;
- }
- con._x = x + offset;
- con._y = y + voffset;
- if(this.borderSize > 0)
- {
- this.borderClip.lineStyle(this.borderSize,10066329,100);
- this.borderClip.drawRect(x,y,cwid,rows[r].maxCellDims.height);
- }
- lastColMax = cwid;
- c++;
- }
- r++;
- }
- this._recalcHeights();
- };
- TableClass.prototype._resizeTextfield = function(oIns, w, h)
- {
- var txt = oIns.content;
- if(txt._width > w)
- {
- txt.wordWrap = true;
- txt._width = w;
- txt._width = Math.round(txt._width);
- trace("text width: " + txt.textWidth);
- if(this.reduceTextFields)
- {
- var h = txt._height;
- var w = txt._width;
- var old_w = 0;
- var txtWidth = txt.textWidth;
- var i = w;
- while(h == txt._height)
- {
- if(i <= 0)
- {
- break;
- }
- if(txt.textWidth < txtWidth)
- {
- break;
- }
- txt._width--;
- i--;
- }
- txt._width = txt._width + 1;
- }
- }
- oIns._width = txt._width;
- };
- TableClass.prototype._recalcHeights = function()
- {
- var rows = this.rows;
- var rc = rows.length;
- var cc;
- var cols;
- var cell;
- this.height = 0;
- var r = 0;
- while(r < rc)
- {
- cols = rows[r].cells;
- cc = cols.length;
- var c = 0;
- while(c < cc)
- {
- cell = cols[c];
- rows[r]._checkMaxCellDims(cell);
- this.height += rows[r].maxCellDims.height;
- c++;
- }
- r++;
- }
- };
- TableClass.prototype._findLargestColumn = function()
- {
- var largestId;
- var largest;
- var cmaxs = this.colWidthMaxs;
- var i = 0;
- while(i < cmaxs.length)
- {
- trace("finding largest: " + cmaxs[i]);
- if(largest < cmaxs[i])
- {
- largest = cmaxs[i];
- largestId = i;
- }
- i++;
- }
- return largestId;
- };
- TableClass.prototype._recalcDimensions = function(newWidth)
- {
- var cw = this._getTableWidth();
- if(newWidth > cw)
- {
- return undefined;
- }
- trace("\n\n----");
- trace("TableClass.prototype._recalcDimensions:");
- trace("current width: " + cw + ", new width: " + newWidth);
- delete this.alteredColumns;
- this.alteredColumns = {};
- this._resizeTableR(cw,newWidth);
- var addback = newWidth - this._getTableWidth();
- var cmaxs = this.colWidthMaxs;
- var prc;
- var cmax = 0;
- var acc = 0;
- for(var nm in this.alteredColumns)
- {
- trace("ALTERED COLUMNS: " + nm);
- if(!isNaN(nm))
- {
- acc++;
- }
- }
- for(var colid in this.alteredColumns)
- {
- trace("Addback: " + colid + ", " + addback / acc);
- this.colWidthMaxs[parseInt(colid)] = this.colWidthMaxs[parseInt(colid)] + addback / acc;
- }
- if(addback / acc > 0)
- {
- }
- this.width = newWidth;
- };
- TableClass.prototype._resizeTableR = function(lastWidth, targetWidth)
- {
- if(lastWidth <= targetWidth)
- {
- return undefined;
- }
- var largest;
- var largestId = 0;
- var cmaxs = this.colWidthMaxs;
- var i = 0;
- while(i < cmaxs.length)
- {
- trace("finding largest: " + cmaxs[i]);
- if(largest < cmaxs[i])
- {
- largest = cmaxs[i];
- largestId = i;
- }
- i++;
- }
- var prc = largest / lastWidth;
- trace("prc: " + prc);
- var ncw = largest * prc;
- cmaxs[largestId] = ncw;
- this.alteredColumns[largestId] = largestId;
- trace("\n\nAFTER:");
- trace("new largest: " + ncw);
- trace("lastWidth: " + lastWidth);
- trace("largest: " + largest);
- trace("targetWidth: " + targetWidth);
- trace("nextWidth: " + (lastWidth - (largest - ncw)));
- if(prc == 1)
- {
- cmax[largestId] = targetWidth;
- return undefined;
- }
- this._resizeTableR(lastWidth - (largest - ncw),targetWidth);
- };
- TableClass.prototype._getTableWidth = function()
- {
- var width = 0;
- var lasti = this.colWidthMaxs.length - 1;
- var i = 0;
- while(i < this.colWidthMaxs.length)
- {
- width += this.colWidthMaxs[i];
- i++;
- }
- return width;
- };
- TableClass.prototype.init = function()
- {
- this.redraw();
- };
- TableRow = function()
- {
- this.cells = [];
- this.maxCellDims = {width:0,height:0};
- };
- TableRow.prototype.addCell = function(cell)
- {
- this.cells.push(cell);
- var cc = cell.getContent();
- var cw = cc == null ? cell.width : cc._width;
- var ch = cc == null ? cell.height : cc._height;
- var mw = this.maxCellDims.width;
- var mh = this.maxCellDims.height;
- this.maxCellDims.width = cw <= mw ? mw : cw;
- this.maxCellDims.height = ch <= mh ? mh : ch;
- };
- TableRow.prototype._checkMaxCellDims = function(cell)
- {
- var cc = cell.getContent();
- var cw = cc == null ? cell.width : cc._width;
- var ch = cc == null ? cell.height : cc._height;
- var mw = this.maxCellDims.width;
- var mh = this.maxCellDims.height;
- this.maxCellDims.width = cw <= mw ? mw : cw;
- this.maxCellDims.height = ch <= mh ? mh : ch;
- };
- TableCell = function(content)
- {
- this.content = content;
- };
- TableCell.prototype.setContent = function(content)
- {
- this.content = content;
- };
- TableCell.prototype.getContent = function()
- {
- return this.content;
- };
- TableCell.prototype.setWidth = function(width, isPercent)
- {
- this.widthIsPercent = isPercent != null ? true : false;
- this.width = width;
- };
- TableCell.prototype.setHeight = function(height, isPercent)
- {
- this.heightIsPercent = isPercent != null ? true : false;
- this.height = height;
- };
- TableCell.prototype.setHAlign = function(halign)
- {
- this.halign = halign;
- };
- TableCell.prototype.setVAlign = function(valign)
- {
- this.valign = valign;
- };
- Image = function(parent, name, depth, url)
- {
- this.$keepAspect = true;
- this.load(parent,name,depth,url);
- };
- Image.prototype.setKeepAspectRatio = function(keepAspect)
- {
- this.$keepAspect = keepAspect;
- };
- Image.prototype.load = function(parent, name, depth, url)
- {
- if(parent != null && name != null && depth != null && url != null)
- {
- if(!this.$mc)
- {
- }
- this.$parent = parent;
- this.$name = name;
- this.$depth = depth;
- this.$url = url;
- this.$mc = parent.createEmptyMovieClip(name,depth);
- this.$mc.drawRect(100,100,100,100);
- this.$mc._width = 100;
- this.$mc.onLoad = function()
- {
- this.onEnterFrame = function()
- {
- if(this._height > 0)
- {
- onLoad();
- delete this.onEnterFrame;
- }
- };
- };
- this.$mc.onLoad.parent = this;
- this.$mc.loadMovie(url);
- return this.$mc;
- }
- };
- Image.prototype.$_onLoad = function()
- {
- this.onEnterFrame = function()
- {
- if(this._height > 0)
- {
- this.onLoad.parent.onLoad.call(this.onLoad.parent,arguments);
- delete this.onEnterFrame;
- }
- };
- };
- Image.prototype.getClipInstance = function()
- {
- return this.$mc;
- };
- Image.prototype.setWidth = function(width)
- {
- if(this.$keepAspect)
- {
- if(this.$aspectRatio == null)
- {
- this.$setAspectRatio();
- }
- this.$mc._xscale = width / this.$mc._width * 100;
- this.$mc._yscale = this.$mc._xscale;
- }
- else
- {
- this.$mc._width = width;
- }
- };
- Image.prototype.setHeight = function(height)
- {
- if(this.$keepAspect)
- {
- this.$mc._yscale = height / this.$mc._height * 100;
- this.$mc._xscale = this.$mc._yscale;
- }
- else
- {
- this.$mc._height = height;
- }
- };
- Image.prototype.resize = function(width, height)
- {
- this.setWidth(width);
- this.setHeight(height);
- };
- Image.prototype.$setAspectRatio = function()
- {
- this.$aspectRatio = this.$mc._width <= this.$mc._height ? this.$mc._height / this.$mc._width : this.$mc._width / this.$mc._height;
- };
- stop();
- bubbleDepthCounter = 70000;
- lineColor = 2309272;
- lineAlpha = 100;
- bubblePlayCounter = 1;
- bubblePlayMax = 99999;
- bubbleHelpSleepTime = 10;
- testFile = "activities/data/C3.U1.S1.EC.A1.xml";
- if(_parent)
- {
- master = _parent;
- }
- else
- {
- master = this;
- }
- if(master.layoutInfo == null)
- {
- var layoutInfo = {};
- layoutInfo.titleTextColor = 3636920;
- layoutInfo.answerRollOverColor = 16695085;
- layoutInfo.answerRollOutColor = 3636920;
- layoutInfo.answerSelectColor = 2309272;
- layoutInfo.questionTextColor = 2309272;
- layoutInfo.instTextColor = 2309272;
- layoutInfo.doAnswerFill = false;
- layoutInfo.rightSideBuffer = 10;
- layoutInfo.box = {};
- layoutInfo.box.x = 260;
- layoutInfo.box.y = 98;
- layoutInfo.box.views = [];
- layoutInfo.box.widthWithBox = 300;
- layoutInfo.box.heightWithBox = 300;
- layoutInfo.box.widthWithoutBox = 300;
- layoutInfo.box.heightWithoutBox = 300;
- layoutinfo.MAX_WIDTH = 520;
- layoutInfo.MAX_HEIGHT = 380;
- layoutInfo.questionIndent = 30;
- layoutInfo.selectionRadius = 6;
- layoutInfo.drawSelectionCircle = true;
- layoutInfo.lineSpacing = 5;
- layoutInfo.selectionBorderThickness = 1;
- layoutInfo.instTextFormat = new TextFormat();
- layoutInfo.instTextFormat.font = "Formata_Bold";
- layoutInfo.instTextFormat.size = 12;
- layoutInfo.instTextFormat.color = layoutInfo.instTextColor;
- layoutInfo.qTextFormat = new TextFormat();
- layoutInfo.qTextFormat.font = "Formata_Normal";
- layoutInfo.qTextFormat.size = 12;
- layoutInfo.qTextFormat.color = layoutInfo.questionTextColor;
- layoutInfo.qTextFormat.align = "right";
- layoutInfo.answerTextFormat1 = new TextFormat();
- layoutInfo.answerTextFormat1.font = "Formata_Normal";
- layoutInfo.answerTextFormat1.size = 12;
- layoutInfo.answerTextFormat1.color = layoutInfo.answerRollOutColor;
- layoutInfo.answerTextFormat2 = new TextFormat();
- layoutInfo.answerTextFormat2.font = "Formata_Normal";
- layoutInfo.answerTextFormat2.size = 12;
- layoutInfo.answerTextFormat2.color = layoutInfo.answerRollOutColor;
- layoutInfo.titleTextFormat = new TextFormat();
- layoutInfo.titleTextFormat.font = "TriplexCondSerifBlack";
- layoutInfo.titleTextFormat.size = 24;
- layoutInfo.titleTextFormat.color = layoutInfo.titleTextColor;
- layoutInfo.matchingCircleColor = 16695085;
- layoutInfo.matchingCircleRadius = 4;
- layoutInfo.matchingCircleSpacer = 50;
- layoutInfo.matchingCircleLineThickness = 2;
- layoutInfo.matchingCircleVertOffset = 4;
- }
- else
- {
- layoutInfo = master.layoutInfo;
- }
- layoutInfo.temp4InstWidth = 250;
- layoutInfo.temp4InstY = 305;
- var ai = new ActivityInfo();
- ai._parent = this;
- ai.onLoad = function(success)
- {
- trace("id: " + this.getIdString());
- trace("type: " + this.type);
- var i = 0;
- while(i < this.questions.question.length)
- {
- trace(i + 1 + ". " + this.questions.question[i].questionText);
- i++;
- }
- this._parent.render();
- trace("Time: " + (getTimer() - t) / 1000);
- };
- if(_parent == null)
- {
- loadActivity(testFile);
- }
- pencilSelected = false;
- pencil.swapDepths(60001);
- pencilHelper.swapDepths(70000);
- pencil._visible = false;
- needsTip = true;
- container = this;
- container.drawPoints = 4;
- container.drawLines_mcs = {};
- container.drawLines_mcs.level = 10000;
- container._snapLines = true;
- container._snapAfter = false;
- pencil.onRelease = function()
- {
- pencilSelected = true;
- pencilHolder.onRelease = pencilHolderRelease;
- Mouse.hide();
- pencil.onMouseMove = function()
- {
- this._x = _root._xmouse;
- this._y = _root._ymouse;
- updateAfterEvent();
- };
- };
-